/***************************************************************************//**
 * @file GUI/DialogConf.cpp
 * @author  Marek M. Cel <marekcel@mscsim.org>
 *
 * @section LICENSE
 *
 * Copyright (C) 2013 Marek M. Cel
 *
 * This file is part of MScSim. You can redistribute and modify it under
 * the terms of GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.
 * 59 Temple Place - SpUite 330, Boston, MA  02111-1307, USA.
 *
 * Further information about the GNU General Public License can also be found
 * on the world wide web at http://www.gnu.org.
 ******************************************************************************/
#ifndef DIALOG_CONF_CPP
#define DIALOG_CONF_CPP
#endif

////////////////////////////////////////////////////////////////////////////////

#include <QSettings>

#include <mscsim_defs.h>

#include <GUI/DialogConf.h>
#include <ui_DialogConf.h>

////////////////////////////////////////////////////////////////////////////////

DialogConf::DialogConf( QWidget *parent ) :
    QDialog ( parent ),
    m_ui ( new Ui::DialogConf )
{
    m_ui->setupUi( this );
    
    settingsRead();
}

////////////////////////////////////////////////////////////////////////////////

DialogConf::~DialogConf()
{
    settingsWrite();
    
    if ( m_ui ) delete m_ui; m_ui = 0;
}

////////////////////////////////////////////////////////////////////////////////

void DialogConf::accept()
{
    //////////////////
    QDialog::accept();
    //////////////////
}

////////////////////////////////////////////////////////////////////////////////

void DialogConf::reject()
{
    //////////////////
    QDialog::reject();
    //////////////////
}

////////////////////////////////////////////////////////////////////////////////

void DialogConf::on_listMenu_currentRowChanged( int iRow )
{
    m_ui->stackedContents->setCurrentIndex( iRow );
}

////////////////////////////////////////////////////////////////////////////////

void DialogConf::settingsRead()
{
    QSettings settings( MSCSIM_ORG_NAME, MSCSIM_APP_NAME );
    
    settings.beginGroup( "dialog_conf" );
    {
        restoreGeometry( settings.value( "geometry" ).toByteArray() );
    }
    settings.endGroup();
}

////////////////////////////////////////////////////////////////////////////////

void DialogConf::settingsWrite()
{
    QSettings settings( MSCSIM_ORG_NAME, MSCSIM_APP_NAME );
    
    settings.beginGroup( "dialog_conf" );
    {
        settings.setValue( "geometry" , saveGeometry() );
    }
    settings.endGroup();
}
